
USE [AnotherSuccessfulProcedure]

IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[KillFormatted]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.KillFormatted
END


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Neil Wilson
-- Create date: 09/03/08
-- Description:	KillFormatted Select
-- =============================================
CREATE PROCEDURE KillFormatted

		   @KillId int
AS
BEGIN

DECLARE @AttackerWeaponName varchar(30),
		@AttackerClass varchar(30),
		@VictimClass varchar(30),
		@AttackerTeam varchar(30),
		@VictimTeam varchar(30)
		
		
		SET @AttackerWeaponName = (SELECT TOP 1 (WeaponFullName) FROM Weapons WHERE WeaponId = (SELECT Attacker_weaponId from Kills where KillId = @KillId))
		SET @AttackerClass = (SELECT TOP 1 (ClassLongName) FROM Classes WHERE ClassId = (SELECT Attacker_ClassId from Kills where KillId = @KillId))
		SET @VictimClass = (SELECT TOP 1 (ClassLongName) FROM Classes WHERE ClassId = (SELECT Victim_ClassId from Kills where KillId = @KillId))
		SET @AttackerTeam = (SELECT TOP 1 (TeamFullname) FROM Teams WHERE TeamId = (SELECT Attacker_Team from Kills where KillId = @KillId))
		SET @VictimTeam = (SELECT TOP 1 (TeamFullname) FROM Teams WHERE TeamId = (SELECT Victim_Team from Kills where KillId = @KillId))
		


SELECT KillId, KillTime, Attacker_playerId, @AttackerWeaponName as [Weapon Name], 
		@AttackerClass as [Attacker Class], @AttackerTeam as [Attacker Team], 
		Victim_playerId, @VictimClass as [Victim Class], @VictimTeam as [Victim Team]
FROM Kills
WHERE KillId = @KillId		

END
GO

 